package com.example.lib_core.mvp.presenter;

import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.OnLifecycleEvent;

import com.example.lib_core.mvp.model.IModel;
import com.example.lib_core.mvp.view.IView;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import io.reactivex.disposables.Disposable;

public class BasePresenter<M extends IModel,V extends IView> implements IPresenter{



    @Inject
    protected M mModel;
    @Inject
    protected V mView;
    protected List<Disposable> disposables=new ArrayList<>();


    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    @Override
    public void onDestory() {
        for (Disposable disposable : disposables) {
            if (!disposable.isDisposed())
                disposable.dispose();
        }
    }
}
